package zx.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import zx.pojo.User;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @创建人: aptx-4869
 * @创建时间:2022/8/10 20:10
 * @Version 1.0
 */
@Controller
public class HelloWorldController {

        /**
         * http://localhost:8080/hello
         */
        @RequestMapping("/hello")
        public ModelAndView hello(){
            Date date=new Date();

            ModelAndView modelAndView = new ModelAndView();
            modelAndView.addObject("date",date);
            modelAndView.setViewName("/views/login");
            return modelAndView;
        }

    @RequestMapping("/index.do")
    public ModelAndView login(User user){
        ModelAndView modelAndView = new ModelAndView();
        if(user != null){
            String userName = user.getUserName();
            String passWord = user.getPassWord();
            Map<String, String> data = new HashMap<String, String>();
            data.put("userName",userName);
            data.put("passWord",passWord);
            modelAndView.addObject("data",data);
            modelAndView.setViewName("/errors/errorLogout");
        }
        return modelAndView;

    }

}
